//
//  IManager+ModuleSearchAll.m
//  RocketProject
//
//  Created by Wu Chengwei on 13-7-13.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+ModuleSearchAll.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "FrameworkRelativeDefines.h"
#import "RCMerchantsListDataModel.h"
#import "GloableEngineService.h"

@implementation IManager(ModuleSearchAll)

-(int64_t)requestSearchAllCityWithName:(NSString *)searchName withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == searchName) {
        return kInvalidRequestId;
    }
    // 异步获取数据
    // 异步获取数据
    NSString *cityID = [[GloableEngineService sharedInstance] selectedCityID];
    CLLocationCoordinate2D coor = [[GloableEngineService sharedInstance] userLocation];
    
    NSString *urlSuffix = [NSString stringWithFormat:kRCSearchAllUrlPrefix,cityID,searchName,coor.latitude,coor.longitude];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    
//    url = @"http://223.4.99.93/17ruyi/api.php?op=app_nearby&action=searchshopname&shopname=店&cityid=3361&lat=39.97252&lon=116.332161";
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCRecommendRestaurantListDataModel class]
                                                     withDataDelegate:delegate];
}

@end
